/*
 * @Author: taoyuqing
 * @Date: 2022-12-21 21:17:04
 * @Description: app入口
 */
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:provider/provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:spree/pages/index_page.dart';
import 'package:spree/routes.dart';
import 'package:spree/utils/api.dart';
import 'package:spree/utils/utils.dart';

import 'provider/model/user_model.dart';
// import 'package:socket_io_client/socket_io_client.dart' as IO;
// import 'package:web_socket_channel/io.dart';
// import 'package:web_socket_channel/web_socket_channel.dart';

void main() {
  runApp(
    MultiProvider(
      providers: [
        ChangeNotifierProvider(create: (context) => UserModel()),
      ],
      child: const MyApp(),
    ),
  );
  // try {
  //   IO.Socket socket = IO.io(
  //       'http://47.95.0.143:9005',
  //       IO.OptionBuilder()
  //           .setPath('/game/socket.io')
  //           .setTransports(['websocket'])
  //           .disableAutoConnect()
  //           .build());
  //   socket.connect();
  //   socket.onConnect((data) {
  //   });
  // } catch (e) {
  //   print(e);
  // }
  // VideoUtil.playVideoByUrl("sounds/dice/dice-lose.mp3");
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      routes: Routes().getRoutes(),
      theme: ThemeData(
        primarySwatch: Utils().createMaterialColor(),
      ),
      home: IndexPage(),
      builder: EasyLoading.init(),
    );
  }
}
